/* eslint-disable no-useless-concat */
import React, {PureComponent} from 'react';
import {Table, Card} from 'antd';
import PropTypes from 'prop-types';
import {TABLE, COMMON_TABLE_QUERY_FAIL_TEXT, COMMON_TABLE_EMPTY_TEXT} from '../constants';
export class TableRejectPanel extends PureComponent {
    state = {
        loading: false
    };
    handleAbandon = id => {
        this.setState({
            loading: true
        });
        this.props.onClickAbandon(id).then(() => {
            this.setState({
                loading: false
            });
        });
    };
    render() {
        const {formatMessage} = this.props.intl;
        const columns = [{
            title: formatMessage({
                id: 'tablePanel.column.sernum',
                defaultMessage: '序号'
            }),
            dataIndex: 'sernum',
            render: (t, d, i) => i + 1
        }, {
            title: formatMessage({
                id: 'tableRejectPanel.table.auditorName',
                defaultMessage: '审核员'
            }),
            dataIndex: 'auditorName'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.dealerCode',
                defaultMessage: '总代'
            }),
            dataIndex: 'dealerCode'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.market',
                defaultMessage: '市场'
            }),
            dataIndex: 'market'
        }, {
            title: formatMessage({
                id: 'tableRejectPanel.table.time',
                defaultMessage: '时间'
            }),
            dataIndex: 'time'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.applicationFee',
                defaultMessage: '申请费用'
            }),
            dataIndex: 'applicationFee'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.materialFee',
                defaultMessage: '材料费用'
            }),
            dataIndex: 'materialFee'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.materialManagementFee',
                defaultMessage: '材料管理费'
            }),
            dataIndex: 'materialManagementFee'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.workingHoursFee',
                defaultMessage: '工时费用'
            }),
            dataIndex: 'workingHoursFee'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.accessoriesFee',
                defaultMessage: '辅料费用'
            }),
            dataIndex: 'accessoriesFee'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.settlementAmount',
                defaultMessage: '结算金额'
            }),
            dataIndex: 'settlementAmount'
        }, {
            title: formatMessage({
                id: 'tablePanel.column.settlementApplicationRate',
                defaultMessage: '结算申请率'
            }),
            dataIndex: 'sluggsettlementApplicationRateishAmount',
        }, {
            title: `${formatMessage({
                id: 'tablePanel.column.settlementCycle',
                defaultMessage: '结算周期'
            })}-天`,
            dataIndex: 'settlementCycle'
        }, {
            title: `${formatMessage({
                id: 'tablePanel.column.billCycle',
                defaultMessage: '单据周期'
            })}-天`,
            dataIndex: 'billCycle'
        }];
        const locale = {
            emptyText: this.props.hasError ? COMMON_TABLE_QUERY_FAIL_TEXT : COMMON_TABLE_EMPTY_TEXT
        };
        return (
            <Card>
                <Table
                    className="white-space-nowrap"
                    columns={columns}
                    dataSource={this.props.data}
                    rowKey="id"
                    pagination={false}
                    loading={this.props.loading || this.state.loading}
                    locale={locale}
                    {...TABLE}/>
            </Card>
        );
    }
}

TableRejectPanel.propTypes = {
    data: PropTypes.array.isRequired,
    hasError: PropTypes.string.isRequired,
    loading: PropTypes.bool.isRequired,
    intl: PropTypes.object,
};
import selectorFactory from 'Shared/utils/immutableToJsSelectorFactory';
const getData = selectorFactory(['page', 'domainData', 'list', 'data']);
const mapStateToProps = state => ({
    data: getData(state),
    loading: state.getIn(['page', 'domainData', 'list', 'isFetching']),
    hasError: state.getIn(['page', 'domainData', 'list', 'hasError']),
});

import {connect} from 'react-redux';
import {injectIntl} from './intl';
export default connect(mapStateToProps, null)(injectIntl(TableRejectPanel));
